<%@ page contentType="text/html; charset=utf-8" %>

<%@ include file="/WEB-INF/jsp/includeCss.jsp"%>
<%@ include file="/WEB-INF/jsp/includeJs.jsp"%>
<%@ include file="/WEB-INF/jsp/includeTaglib.jsp"%>

<script type="text/javascript">
<!--
var setting = {
		view : {
			dblClickExpand : false
		},
		data : {
			simpleData : {
				enable : true
			}
		},
		callback : {
			onDblClick:function(e, treeId, treeNode){
				if(!treeNode.isParent && !treeNode.isEmploy){
					var icon=treeNode.icon;
					treeNode.icon = "<c:url value='/css/zTreeStyle/img/loading.gif' />";
					$.fn.zTree.getZTreeObj(treeId).updateNode(treeNode);
					$.getJSON("<c:url value='/json/findAllChildEmployeesBy.html?orgCode=' />"+treeNode.id, function(jsonData){
						if(jsonData.length>0){
							var zTree = $.fn.zTree.getZTreeObj(treeId);
							for(var i=0;i<jsonData.length;i++){
								jsonData[i].isEmploy=true;
							}
							zTree.addNodes(treeNode, jsonData);
						}else{
							alert('未找到相关数据');
						}

						treeNode.icon = icon;
						$.fn.zTree.getZTreeObj(treeId).updateNode(treeNode);
					});
				}
			},
			onClick:function(e, treeId, treeNode){
				if(treeNode.isEmploy){
					var cityObj = $('#employee');
					cityObj.attr('value', treeNode.name);
					$('#orgnizationEmployee').val(treeNode.id);
					$('#employeeName').val(treeNode.name);
				}
			}
		}
	};

//-->
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="5">
  <tr>
    <td valign="top">
      <table class="dbborder" width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td valign="bottom" class="blueTableBg">&nbsp;账号维护&nbsp;-&nbsp;编辑模板</td>
        </tr>
        <tr>
          <td>
            <table width="100%" border="0" cellpadding="0" cellspacing="5">
              <tr>
                <td>
                  <table width="100%" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td class="dashTopLeft"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                      <td class="dashTop" width=100%><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                      <td class="dashTopRight"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                    </tr>
                    <tr>
                      <td class="dashLeft"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                      <td align="center">

                      <form:form target="tempFrame" commandName="userForm" id="editUserForm" method="post"  action="editUserForm.html">
                        <table width="100%" border="0" cellpadding="0" cellspacing="3">

		                      <input type="hidden" name="updatekey" value="${user.id}">

		                      <input type="hidden" id="oldRoleId" name="oldRoleId" value="${user.permissionRole.id}">

                          <tr>
                            <td width="114" height="20" class="globalText">帐号</td>
                            <td height="20" class="globalText">
                            <input type="text" readonly="readonly" class="txtbox required" size="20" name="loginName" value="${user.loginName}"/>
                            </td>
                          </tr>
                          <tr>
                            <td width="114" height="20" class="globalText">密码</td>
                            <td height="20" class="globalText">
                            	<input  type="password" class="txtbox required" size="20" name="password" value="${user.password}"/>
                            </td>
                          </tr>
                          <tr>
                            <td width="114" height="20" class="globalText">角色</td>
                            <td height="20" class="globalText">
                            	<form:select path="roleIdSlt" >
							               		<form:options  items="${roles}" itemValue="id" itemLabel="name" />
						               		</form:select>
                            </td>
                            </td>
                          </tr>
                          <tr>
                             <td width="114" height="20" class="globalText">员工名称</td>
                             <td height="20" class="globalText">
                            	<input value="${user.employee.empId}" type="hidden" name="orgnizationEmployee" id="orgnizationEmployee"/>
                            	<input readonly="readonly" type="text" id="employee" name="employeeName" class="txtbox required" size="20" value="${user.employee.name}" onclick="javascript:showRadioTree('<c:url value="/json/findAllOrgnizations.html" />',this.id,setting);" />
                           	 </td>
                          </tr>
                          <tr>
                            <td width="114" height="20" class="globalText">显示名称 </td>
                            <td height="20" class="globalText">
                            	<input id="displayName" type="text" class="txtbox required" size="20" name="displayName" value="${user.displayName}"/>
                            </td>
                          </tr>
                          <tr>
                            <td width="114" height="20" class="globalText">手机IMEI码</td>
                            <td height="20" class="globalText">
                                <input id="imei" type="text" class="txtbox" size="20" name="imei" value="${user.imei}"/>
                            </td>
                          </tr>
                          <tr>
                            <td height="20" class="globalText">
                                <c:choose>
                                    <c:when test="${user.disableImeiValidate==1}">
                                        <input id="disableImeiValidate" type="checkbox" class="txtbox" name="disableImeiValidate" checked value="1"/>
                                    </c:when>
                                    <c:otherwise>
                                        <input id="disableImeiValidate" type="checkbox" class="txtbox" name="disableImeiValidate" value="1"/>
                                    </c:otherwise>
                                </c:choose>
                                <c:if test="${user.disableImeiValidate==1}">
                                </c:if>
                                <label for="disableImeiValidate">不使用手机IMEI登录限制</label>
                            </td>
                          </tr>
                          <tr>
                            <td align="center" colspan="2">
                              <table border="0" cellpadding="0" cellspacing="2">
                                <tr>
                                  <td><input type="button" class="btnStyle" value="  保存  " onclick="javascript:doSubmit()"></td>
                                  <td><input type="button" class="btnStyle" value="  取消  " onclick="javascript:window.location='<c:url value='/userList.html' />'"></td>
                                </tr>
                              </table>
                            </td>
                          </tr>
                        </table>
                        </form:form>
                      </td>
                      <td class="dashRight"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                    </tr>
                    <tr>
                      <td class="dashBottomLeft"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                      <td class="dashBottom" width=100%><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                      <td class="dashBottomRight"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>



<script language="javascript">

	function doSubmit(){
		document.getElementById("editUserForm").action = "<c:url value='/editUserForm.html' />";

		if($("#editUserForm").valid()){
			document.getElementById("editUserForm").submit();

			$("#oldRoleId").val($("#roleIdSlt").val());
		}
	}


	$().ready(function() {
		var validate=$("#editUserForm").validate({
			showErrors: customShowErrors,
			onfocusout:false,
			onkeyup:false,
			onclick:false
		});

	});

	function submitCallbackSuccess(data){
		window.location="<c:url value='/userList.html' />";
	}
</script>
